import request from '@/utils/request'

export const getEmployeeSimple = () => {
  return request({
    url: '/sys/user/simple'
  })
}
// 查询列表
export const getEmployeesListApi = (params) => {
  return request({
    url: '/sys/user',
    method: 'get',
    params
  })
}

// 查询单个
export const getEmployeesInfoApi = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'get'
  })
}

// 添加
export const addEmployeesApi = (data) => {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}

// 修改
export const editEmployeesApi = (data) => {
  return request({
    url: '/sys/user/' + data.id,
    method: 'put',
    data
  })
}

// 删除
export const delEmployeesApi = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'delete'
  })
}

// 批量导入员工的方法
export const importEmployeesApi = (data) => {
  return request({
    url: '/sys/user/batch',
    method: 'post',
    data
  })
}
/** *
 *  读取用户详情的基础信息
 * **/
export function getPersonalDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'put',
    data
  })
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetail(id) {
  return request({
    url: `/employees/${id}/jobs`
  })
}

/**
 * 保存岗位信息
 * ****/
export function updateJob(data) {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: 'put',
    data
  })
}
// 给员工配置角色
export const assignRoles = (data) => {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
